#ifndef MYARRAY_H
#define MYARRAY_H

#include <QtCore>

namespace sk {

class MyArray;

void mySwap(MyArray* arr, int x, int y);

class MyArray {
public:
    MyArray();
    ~MyArray();

    MyArray(const MyArray& arr);
    MyArray(int *arr, int length);

    friend void mySwap(MyArray* arr, int x, int y);

    void add(int val);
    int get(int index) const;
    int getSize() const { return size; }
    int takeLast();

    int operator[](int index) const { return get(index); }
    MyArray& operator=(const MyArray& arr);

    void print();
private:
    static const int DEFAULT_ARR_SIZE = 5;

    int* arr;
    int arrSize;
    int size;

    bool bIsOwnsMemory;
};

}

#endif // MYARRAY_H
